<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vue原理实践</title>
  </head>
  <body>
    <!-- <script src="https://cdn.jsdelivr.net/npm/vue@2"></script> -->
    <script src="./index.js"></script>
    <script>
      const vm = new Vue({
        data: {
          message: "Hello Vue!",
          person: {
            name: "张三",
            age: 20,
          },
        },
        watch: {
          // message(newVal, oldVal) {
          //   this.person.age = 200;
          //   console.log(`新值：${newVal}，旧值：${oldVal}`);
          // },
          // person(newVal, oldVal) {
          //   console.log(`新值：${newVal}，旧值：${oldVal}`);
          // },
          'person.gender'(newVal, oldVal) {
            console.log('changed', newVal, oldVal)
          }
        },
      });
      vm.$set(vm.person, 'gender', '男')
    </script>
  </body>
</html>
